//
//  SizeFitViewController.m
//  UniverseProject
//
//  Created by king on 2021/6/24.
//  Copyright © 2021 Cloud2209. All rights reserved.
//

#import "SizeFitViewController.h"

@interface SizeFitViewController ()

@end

@implementation SizeFitViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UILabel *label = [[UILabel alloc] init];
    [label setBackgroundColor:[UIColor grayColor]];
    [label setFont:[UIFont systemFontOfSize:20]];
    label.text = @"北京欢饮您！！！";

    //sizeToFit:直接改变了这个label的宽和高，使它根据上面字符串的大小做合适的改变
    [label sizeToFit];

    NSLog(@"width=%.1f  height=%.1f ", label.frame.size.width, label.frame.size.height);
    [self.view addSubview:label];
    
    
}


@end
